<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page import="java.util.List" %>
<%@ page import="com.javaweb.oa02.web.action.user" %>
<%@page contentType="text/html;charset=UTF-8"%>

<!DOCTYPE html>
<html>
	<head>
		<meta charset='utf-8'>
		<title align='center'>部门列表页面</title>
	</head>
	<body>
	<a href='${pageContext.request.contextPath}/dept/exit'>[安全退出]</a>
	<h3>欢迎${username}，在线人数${onlineCount}</h3>

	<%--删除是没有页面展示的，是跳出一个确认框，如果点“确定”，执行删除--%>
	<script type="text/javascript">
		function del(deptno){
			var ok = window.confirm("亲，删了不可恢复哦！");
			if(ok){
				/*注意html的base标签可能对JS代码不起作用。所以JS代码最好前面写上"/oa" */
				document.location.href='${pageContext.request.contextPath}/dept/delete?deptno='+deptno;
			}
		}
	</script>

		<h1 align='center'>部门列表</h1 >
		<hr>
		<table h1 border = '1px' align='center'>
			<tr>
				<th>序号</th>
				<th>部门序号</th>
				<th>部门名称</th>
				<th>操作</th>
			</tr>
		<%--用jstl替代掉jsp--%>
		<c:forEach items="${userList}" varStatus="userStatus" var="user">
			<tr>
				<td>${userStatus.count}</td>
				<td>${user.deptno}</td>
				<td>${user.dname}</td>
				<td>
					<a href='${pageContext.request.contextPath}/dept/edit?deptno= ${user.deptno}'>修改</a>
					<a href='${pageContext.request.contextPath}/dept/detail?deptno=${user.deptno}'>详情</a>
					<a href='javascript:void(0)' onclick='del(${user.deptno})'>删除</a>
				</td>
			</tr>
		</c:forEach>

		</table>
		<hr>
		<a href='${pageContext.request.contextPath}/add.jsp' >新增部门</a>
	</body>
</html>
